package Eyjafjalla.power;

import Eyjafjalla.patch.MelodyPatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInHandAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.cards.status.Dazed;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class MelodyMemoryPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:MelodyMemoryPower";
    private static final PowerStrings powerStrings;

    public MelodyMemoryPower(AbstractCreature owner,int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        String path128 = "EyjafjallaResources/img/power/MelodyMemoryPower_84.png";
        String path48 = "EyjafjallaResources/img/power/MelodyMemoryPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
        enableExtraAmount = true;
        extraAmount = 6;
        this.updateDescription();
    }

    AbstractCard c = new Dazed();

    public void onAfterUseCard(AbstractCard card, UseCardAction action) {
        if(card.type!= AbstractCard.CardType.SKILL)
            return;
        extraAmount--;
        if(extraAmount<=0){
            this.flash();
            extraAmount = 6;
            this.addToBot(new DamageAction(AbstractDungeon.player, new DamageInfo(this.owner, this.amount, DamageInfo.DamageType.THORNS), AbstractGameAction.AttackEffect.BLUNT_LIGHT));
            this.addToBot(new MakeTempCardInHandAction(c,1));
        }
        this.updateDescription();
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0] + extraAmount + powerStrings.DESCRIPTIONS[1] + amount + powerStrings.DESCRIPTIONS[2];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}




